﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="fhdb" content="true">
    <title>我的保证金</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/mybond.css">
    <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
</head>
<body>
    <div class="phoneError">
    </div>
    <div class="backBox" onclick="javascript:location.href = 'personalCenter.html';">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </div>
    <div class="topTitle">
        我的保证金
    </div>
    <div class="bd_banner">
        <div>当前保证金(元)</div>
        <div id="TB_BZJ_PRICE"></div>
        <div>每日最多可购买商品：<span id="TB_BZJ_COUNT"></span></div>
    </div>
    <div class="yy_all">
        <div class="yy_title recharge">
            <img src="images/chongzhi.png" />
            <span>充值</span>
            <span style="float:right;">></span>
        </div>
        <div class="yy_title withdrawal">
            <img src="images/tixian.png" />
            <span>提现</span>
            <span style="float:right;">></span>
        </div>
        <div class="yy_title bondbill">
            <img src="images/jilu.png" />
            <span>账单</span>
            <span style="float:right;">></span>
        </div>
    </div>
    <!-- 提现 -->
    <div class="covers">
    </div>
    <div class="bigWithdrawalBox">
        <div>
            <span>余额：￥</span> <span class="price"></span>
        </div>
        <div>
            <span>提现金额：</span>
            <input type="text" placeholder="请输入提现金额" onkeyup="clearNoNum(this)" id="txprice">
        </div>
        <p>
            1、提现后3-5个工作日到账<br />
            2、请务必将支付授权信息填写正确
        </p>
        <div>
            <button class="cancel-withdrawal">
                取消
            </button>
            <button class="confirm-withdrawal">
                确认
            </button>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "../../BaseRefWeb.aspx?stype=ISpBondmanageFun&method=GetDqBond&type=sp",
            success: function (result) {
                var data = JSON.parse(result);
                if (data.msg == "_timeout") {
                    window.location.href = "../UserLogin/Login.html";
                }
                else {
                    $("#TB_BZJ_PRICE").text(data.TB_BZJ_PRICE.toFixed(2));
                    $("#TB_BZJ_COUNT").text(data.TB_BZJ_COUNT);
                }
            }
        });
        $(".recharge").click(function () {
            location.href = 'rechargebond.html';
        })
        $(".bondbill").click(function () {
            location.href = 'bondbill.html';
        })
        // 提现
        $(".withdrawal").click(function () {
            $.ajax({
                type: "post",
                url: "../../BaseRefWeb.aspx?stype=ISpBondmanageFun&method=GetDqBond&type=sp",
                success: function (result) {
                    var data = JSON.parse(result);
                    if (data.msg == "_timeout") {
                        window.location.href = "../UserLogin/Login.html";
                    }
                    else {
                        $(".price").text(data.TB_BZJ_PRICE.toFixed(2));
                    }
                }
            });
            $(".covers").toggle()
            $(".bigWithdrawalBox").toggle()
        })
        $(".cancel-withdrawal").click(function () {
            $(".covers").toggle()
            $(".bigWithdrawalBox").toggle()
        })
        $(".confirm-withdrawal").click(function () {
            $(".confirm-withdrawal").hide();
            $.ajax({
                type: "post",
                data: { TB_BZJ_PRICE: $("#txprice").val() },
                url: "../../BaseRefWeb.aspx?stype=ISpBondmanageFun&method=DoTxBond&type=sp",
                success: function (result) {
                    var data = JSON.parse(result);
                    if (data.msg == "_timeout") {
                        window.location.href = "../UserLogin/Login.html";
                    }
                    else {
                        $('.phoneError').text(data.msg);
                        var top = ($(window).height() - $('.phoneError').height()) / 2;
                        var left = ($(window).width() - $('.phoneError').width()) / 2;
                        var scrollTop = $(document).scrollTop();
                        var scrollLeft = $(document).scrollLeft();
                        $('.phoneError').css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft }).show();
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000)
                    }
                }
            });
        })
    })
    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');//只能输入两个小数
        if (obj.value.indexOf(".") < 0 && obj.value != "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
            obj.value = parseFloat(obj.value);
        }
    }
</script>